package com.helloworld.upload.domain;

import java.util.ArrayList;
import java.util.List;

import com.helloworld.common.dao.SimpleBizDao;

public class UploadInfo {
	
	private String targetTable;
	
	private SimpleBizDao dao;
	
	public UploadInfo(SimpleBizDao simpleBizDao) {
		this.dao = simpleBizDao;
	}
	
	public String getTargetTable() {
		return targetTable;
	}
	
	public SimpleBizDao getDao() {
		return dao;
	}
	
	List<ColumnInfo> columns = new ArrayList<ColumnInfo>();
	
	public List<ColumnInfo> getColumns() {
		return columns;
	}
	
	public UploadInfo(String targetTable, SimpleBizDao dao) {
		this.targetTable = targetTable;
		this.dao = dao;
	}
	
	public ColumnInfo addColumnInfo(int excelColumnIndex, String targetColumn, 
			ValidateRule.TypeSize.EnumFieldType fieldType, int size, boolean keyColumn) {
		return addColumnInfo(excelColumnIndex, targetColumn, fieldType, size, 0, keyColumn);
	}	
	
	public ColumnInfo addColumnInfo(int excelColumnIndex, String targetColumn, 
			ValidateRule.TypeSize.EnumFieldType fieldType, int size, int scale, boolean keyColumn) {
		ColumnInfo column = new ColumnInfo(excelColumnIndex, targetColumn, fieldType, size, scale, keyColumn);
		column.setUploadInfo(this);
		columns.add(column);
		
		return column;
	}	
}
